package com.dgz.common.core.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.dgz.common.core.domain.R;
import com.dgz.common.core.domain.TableDataInfo;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2024/12/10/11:09
 * @Description:
 */
public class BaseController {


    public R<Void> toR(int row) {
        return row > 0 ? R.ok() : R.fail();
    }

    public R<Void> toR(boolean flag) {
        return flag? R.ok() : R.fail();
    }

    public TableDataInfo getTableDataInfo(List<?> list) {
        if (CollectionUtil.isEmpty(list)) {
            return TableDataInfo.empty();
        }
//        new PageInfo<>(list).getTotal(); // 符合查询条件的题目总数
        return TableDataInfo.success(list, new PageInfo<>(list).getTotal()); // 符合查询条件的题目总数);
    }
}
